<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/30
 * Time: 16:14
 */

namespace App\LogicService;

use App\LogicService\Contracts\OphthalmologyMacularEdemaLogicContract;
use App\Models\OphthalmologyMacularEdema;


class OphthalmologyMacularEdemaLogic extends BaseLogic implements OphthalmologyMacularEdemaLogicContract
{
    public function update($record_id, $value)
    {
        $ophthalmologyMacularEdema = OphthalmologyMacularEdema::firstOrCreate(['record_id' => $record_id]);
        $ophthalmologyMacularEdema->left = $value['left'];
        $ophthalmologyMacularEdema->left_edema = $value['left_edema'];
        $ophthalmologyMacularEdema->left_thickness = $value['left_thickness'];
        $ophthalmologyMacularEdema->right = $value['right'];
        $ophthalmologyMacularEdema->right_edema = $value['right_edema'];
        $ophthalmologyMacularEdema->right_thickness = $value['right_thickness'];
        $ophthalmologyMacularEdema->remark = $value['remark'];
        $ophthalmologyMacularEdema->save();

        return $ophthalmologyMacularEdema;
    }

    public function show($record_id)
    {
        $ophthalmologyOrdinary = OphthalmologyMacularEdema::where('record_id' , $record_id)
            ->first();
        if($ophthalmologyOrdinary){
            $ophthalmologyOrdinary = $ophthalmologyOrdinary->toArray();
        }else{
            $ophthalmologyOrdinary = [];
        }
        return $ophthalmologyOrdinary;
    }
}